<?php

require_once 'tpl/use/Posting.php';
require_once 'util/smurfs.php';

switch( $_REQUEST['type'] ) {
  case 'EDIT':
    handlePostEdit(); break;
  case 'NEW':
  default:
    handleNewPost(); break;
}

function handlePostEdit() {
  require 'db/get/post.php';

  if ( $_REQUEST['pnum'] < 1 && $_REQUEST['tnum'] < 1 ) {
    die( "breakage" ); // breakage
  }
  $post = getPost((int)intval($_REQUEST['tnum']), (int)intval($_REQUEST['pnum']));

  $post['datum'] = unsmurf($post['datum'], $post['smurfKey']);

  require 'tpl/use/EditPost.php';
  skin_EditPost( $post );
}

function handleNewPost() {
  
  require 'tpl/use/NewPost.php';
  skin_NewPost( (int)intval($_REQUEST['fnum']), (int)intval($_REQUEST['tnum']) );
}

?>
